/*
 * 企业列表
 * @Author: along
 * @Date: 2019-12-10 16:24:00
 */
<template>
    <div class="container companyList">
        <!-- header -->
        <div class="headerBox">
            <div class="header-left">
                <div class="header-box">
                    <el-radio-group
                        v-model="searchType"
                        @change="getTableData(1)"
                        size="small"
                    >
                        <el-radio-button label="">全部</el-radio-button>
                        <el-radio-button label="1">商城</el-radio-button>
                        <el-radio-button label="2">工作</el-radio-button>
                        <el-radio-button label="3">学习</el-radio-button>
                    </el-radio-group>
                </div>
            </div>
            <div class="header-right">
                <el-input
                    v-model="keyword"
                    placeholder="请输入内容"
                    suffix-icon="el-icon-search"
                    size="small"
                    clearable
                    @change="getTableData(1)"
                    @keyup.native.enter="getTableData(1)"
                />
            </div>
        </div>
        <!-- /header -->

        <!-- table -->
        <el-table
            :data="tableData"
            height="100%"
            style="width: 100%;"
            border
            ref="companyList"
        >
            <el-table-column
                type="index"
                width="80"
                label="序号"
                align="center"
            />
            <el-table-column
                prop="keyword"
                label="搜索内容"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="center"
            >
                <template slot-scope="scope">
                    <span
                        @click="fnGoFront(scope.row.keyword)"
                        class="cursor-font"
                    >{{ scope.row.keyword }}</span>
                </template>
            </el-table-column>
            <el-table-column
                prop="search_count"
                label="搜索次数"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="center"
            />
            <el-table-column
                prop="rank_index"
                label="搜索排名"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="center"
            />
        </el-table>
        <!-- /table -->

        <!-- /分页 -->
        <!-- <div class="pagination-wrapper clearfix">
            <el-pagination
                background
                layout="total, prev, pager, next"
                :current-page.sync="page.now_page"
                :total="page.total_count"
                :page-size="page.page_size"
                @current-change="getTableData"
            />
        </div> -->
    </div>
</template>

<script>
export default {
    /**
     * @param  {Object}    authResult           //表单权限
     * @param  {Array}     tableData            //表单数据
     * @param  {Object}    page                 //表单分页
     * @param  {Object}    header               //表单检索字段
     * @param  {Array}     companyList          //表单检索字段
     */
    data () {
        return {
            keyword: '',
            searchType: 1,
            page: {
                now_page: 1,
                total_count: 0,
                page_size: 0
            },
            tableData: [],
            authResult: {}
        };
    },
    filters: {},
    computed: {},
    watch: {},
    mounted () {
        this.authResult = this.$route.meta.authResult;
        this.fnBreadcrumb();
        this.getTableData();
    },
    methods: {
        /**
         * 设置表单header
         */
        fnBreadcrumb () {
            this.$store.commit('SET_HEADER', [{ title: "APP后台"},{title: 'APP搜索记录'}]);
        },

        /**
         * 获取表格数据
         */
        getTableData (page) {
            this.$post('/student/search_log%5Cget_rank_list', {
                // page_id: page || this.page.now_page,
                type: this.searchType,
                keyword: this.keyword
            }, resp => {
                if (resp.code == 1) {
                    this.tableData = resp.data.list.splice(0,100);
                    // this.page.now_page = resp.data.page.now_page;
                    // this.page.total_count = resp.data.page.total_count;
                    // this.page.page_size = resp.data.page.page_size;
                }
            });
        },

        /**
         * 跳转
         */
        fnGoFront(keyword) {
            window.open(`${this.$shopBaseUrl}/resource?keyword=${keyword}`);
            // if(window.location.host == 'phaadmin.wxhand.com') {
            //     window.open('http://cms.zsdx.cn/resource?keyword=' + keyword);
            // }else{
            //     window.open('http://gt.wxhand.com/resource?keyword=' + keyword);
            // }
        },

        /**
         * 过滤函数
         */
        emptyFormatter(row, column, val) {
            if (!val) return '--';
            return val;
        }
    }
};
</script>

<style lang="less" scoped>
    .container {
        background-color: #fff;
        padding: 10px 15px 5px 15px;
        display: flex;
        flex-direction: column;
        position: relative;
        width: 100%;
        .headerBox {
            position: relative;
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 10px;
            .header-left, .header-right {
                display: flex;
                align-items: center;
                height: 32px;
            }
            .header-box {
                display: flex;
                margin-right: 15px;
                align-items: center;
                color: #606266;
                // margin-bottom: 10px;
                &-title {
                    margin-right: 2px;
                    white-space: nowrap;
                }
            }
        }
        /* 表单 */
        .scope-price {
            width: 50px;
            height: 50px;
        }
        /* 字体高亮 */
        .cursor-font {
            color: rgb(64, 158, 255);
            cursor: pointer;
        }
        /* 分页 */
        .pagination-wrapper {
            padding-top: 10px;
            padding-bottom: 10px;
            .el-pagination {
                float: right;
                padding: 0;
                background-color: transparent;
            }
        }
    }
    /* 排序 */
    .sort-wrap {
        display: flex;
        align-items: center;
        cursor: pointer;
        .sort-spliter {
            width: 1px;
            height: 12px;
            background: rgba(235, 235, 235, 1);
            margin: 0 10px;
            }
            .btn-sort {
            font-size: 14px;
            line-height: 1;
            color: #ccc;
            &:hover {
                color: #20a0ff;
            }
        }
    }
</style>
<style lang="less">
    .companyList .el-table__body-wrapper .el-table__body .el-table__row td {
        border-right: none;
    }
    .companyList .el-table__header-wrapper .el-table__header .has-gutter tr th {
        border-right: none;
    }
    .companyList .el-table .el-table_1_column_6  .cell {
        position: relative;
    }
    .companyList .el-range-editor--small .el-range-separator{
        padding: 0 1px !important;
    }
</style>
